<extend name="./Common/View/EasyUI/treegrid.html"/>

<block name="west">
    <div data-options="region:'west',split:true,collapsible:false" title="应用列表" style="width: 200px; overflow: hidden;">
        <ul class="easyui-datalist" id="appList" lines="true" style="width:100%" data-options="url:'{$Think.config.API_BASE}Sys/Application/lists',idField:'id',textField:'title',onClickRow:changeApp,onLoadSuccess:setApp">

        </ul>
    </div>
</block>

<block name="toolbar">
    <a onclick="curd.dialog('__URL__/add/app_id/{$appId}', '添加菜单')" href="javascript:void(0);" class="easyui-linkbutton"
       data-options="plain:true,iconCls:'icon-plus'">添加</a>
    <a onclick="curd.batch('enable')" href="javascript:void(0);" class="easyui-linkbutton"
       data-options="plain:true,iconCls:'icon-ok-circle'">启用</a>
    <a onclick="curd.batch('disable', '您确认要禁用这些菜单吗？')" href="javascript:void(0);" class="easyui-linkbutton"
       data-options="plain:true,iconCls:'icon-remove-circle'">禁用</a>
    <a onclick="curd.reload();" href="javascript:void(0);" class="easyui-linkbutton"
       data-options="plain:true,iconCls:'icon-refresh'">刷新</a>
</block>

<block name="columns">
    <thead data-options="frozen:true">
    <tr>
        <th data-options="field:'id',checkbox:true"></th>
        <th data-options="field:'idField',width:120,formatter:format_operation">操作</th>
        <th data-options="field:'title',width:150,sortable:true">菜单名称</th>
    </tr>
    </thead>
    <thead>
    <tr>
        <th data-options="field:'url',width:150">操作地址</th>
        <th data-options="field:'type',width:150,formatter:format_type">菜单类型</th>
        <th data-options="field:'status',width:50,formatter:format_status">状态</th>
        <th data-options="field:'sort',width:50">排序</th>
    </tr>
    </thead>
</block>

<block name="script">
    <script type="text/javascript">
        gridOption.queryParams.app_id = {$appId};
        gridOption.height = $(window).height() - 30;

        function format_operation(value, row, index) {
            return format_button(row.id, ['edit','delete']);
        }
        function format_type(value, row, index) {
            if(value == 1){
                return '内部功能';
            }else if(value == 2){
                return '外部链接';
            }else{
                return '-';
            }
        }
        function changeApp(index, row) {
           app.jump('__URL__/index/app_id/'+row.id);
        }
        function setApp() {
            $('#appList').datalist("selectRecord", {$appId});
        }
    </script>
</block>